/**
  ******************************************************************************
  * @file    CFG_GetNetworkParameters.c
  * @author  exatron
  * @version V1.0.0
  * @date    segunda, 22 de dezembro de 2014
  * @brief   Retorna os parâmetros de rede.
  ******************************************************************************
  * @attention
  *
  *
  ******************************************************************************
  */

/**
  * @addtogroup CFG
  * @{
  */

/* Includes ------------------------------------------------------------------*/
#include <common.h>

/* External functions --------------------------------------------------------*/

/**
  * @defgroup CFG_Functions
  * @{
  */

/**
  * @brief  Retorna os parâmetros de rede.
  * @param  Nenhum
  * @retval Devolve pela serial os parâmetros de rede
  */
void CFG_GetNetworkParameters(void)
{
	char mode[50];
	char ip[50];
	char netmask[50];
	char gateway[50];

	bzero(mode, sizeof(mode));
	bzero(ip, sizeof(ip));
	bzero(netmask, sizeof(netmask));
	bzero(gateway, sizeof(gateway));

	strcpy(mode, aux_FileRdLine(PATH_CONF, "network", "Erro GetNetwork\r\n"));
	strcpy(ip, aux_FileRdLine(PATH_CONF, "ip", "Erro GetNetwork\r\n"));
	strcpy(netmask, aux_FileRdLine(PATH_CONF, "netmask", "Erro GetNetwork\r\n"));
	strcpy(gateway, aux_FileRdLine(PATH_CONF, "gateway", "Erro GetNetwork\r\n"));

	if(atoi(mode) == DHCP_NETWORK)
		aux_USART0_puts("%s=%s\r\n","CFG_GNP",mode);
	else if(atoi(mode) == STATIC_NETWOTK)
		if(strcmp(ip, gateway) == 0)
			aux_USART0_puts("%s=%s;%s;%s\r\n","CFG_GNP",mode,ip,netmask);
		else
			aux_USART0_puts("%s=%s;%s;%s;%s\r\n","CFG_GNP",mode,ip,netmask,gateway);
	else
		aux_USART0_puts("%s=%s;%s;%s;%s\r\n","CFG_GNP",mode,ip,netmask,gateway);

	aux_SetBusy(FALSE);
}

/**
  * @}
  */

/**
  * @}
  */



